/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import javax.swing.JPanel;

/**
 *
 * @author Igor
 */
public class JanelaPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form JanelaPrincipal
     */
    PainelInicial painelInicial;
    private PainelAdministrador painelDoAdministrador;
    
    public JanelaPrincipal() {
        super("Frente de Caixa");
        initComponents();
        
        this.setExtendedState(MAXIMIZED_BOTH);
        Toolkit tk = Toolkit.getDefaultToolkit();
        int xSize = ((int) tk.getScreenSize().getWidth());
        int ySize = ((int) tk.getScreenSize().getHeight());
        this.setSize(xSize, ySize);

        painelInicial = new PainelInicial();
        painelPrincipal.removeAll();
        this.painelPrincipal.setLayout(new BorderLayout());
        this.painelPrincipal.setAutoscrolls(true);
        painelPrincipal.add(painelInicial);
        this.repaint();
    }

    public JPanel getPainelPrincipal() {
        return painelPrincipal;
    }

    public void setPainelPrincipal(JPanel painelPrincipal) {
        this.painelPrincipal = painelPrincipal;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        barraBotoes = new javax.swing.JToolBar();
        apresentacaoBotao = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        botaoCliente = new javax.swing.JButton();
        vendaDeProdutos = new javax.swing.JButton();
        zonaDoAdministrador = new javax.swing.JButton();
        gerarRelatorios = new javax.swing.JButton();
        botaoEstoque = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        painelPrincipal = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        barraBotoes.setRollover(true);
        barraBotoes.setBorderPainted(false);
        barraBotoes.setPreferredSize(new java.awt.Dimension(100, 100));

        apresentacaoBotao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/home.png"))); // NOI18N
        apresentacaoBotao.setText("Apresentação");
        apresentacaoBotao.setFocusable(false);
        apresentacaoBotao.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        apresentacaoBotao.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        apresentacaoBotao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                apresentacaoBotaoActionPerformed(evt);
            }
        });
        barraBotoes.add(apresentacaoBotao);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/glasses.png"))); // NOI18N
        jButton2.setText("Gerenciar Produtos");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        barraBotoes.add(jButton2);

        botaoCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cliente.png"))); // NOI18N
        botaoCliente.setText("Gerenciar Clientes");
        botaoCliente.setFocusable(false);
        botaoCliente.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botaoCliente.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botaoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoClienteActionPerformed(evt);
            }
        });
        barraBotoes.add(botaoCliente);

        vendaDeProdutos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/transcacoes.png"))); // NOI18N
        vendaDeProdutos.setText("Venda de Produtos");
        vendaDeProdutos.setFocusable(false);
        vendaDeProdutos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        vendaDeProdutos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        vendaDeProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vendaDeProdutosActionPerformed(evt);
            }
        });
        barraBotoes.add(vendaDeProdutos);

        zonaDoAdministrador.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/admin.png"))); // NOI18N
        zonaDoAdministrador.setText("Zona do Administrador");
        zonaDoAdministrador.setFocusable(false);
        zonaDoAdministrador.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        zonaDoAdministrador.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        zonaDoAdministrador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zonaDoAdministradorActionPerformed(evt);
            }
        });
        barraBotoes.add(zonaDoAdministrador);

        gerarRelatorios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/relatorio.png"))); // NOI18N
        gerarRelatorios.setText("Gerar Relatórios");
        gerarRelatorios.setFocusable(false);
        gerarRelatorios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        gerarRelatorios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        gerarRelatorios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerarRelatoriosActionPerformed(evt);
            }
        });
        barraBotoes.add(gerarRelatorios);

        botaoEstoque.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/estoque.png"))); // NOI18N
        botaoEstoque.setText("Gerenciar Estoque");
        botaoEstoque.setFocusable(false);
        botaoEstoque.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botaoEstoque.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botaoEstoque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoEstoqueActionPerformed(evt);
            }
        });
        barraBotoes.add(botaoEstoque);

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 8, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout painelPrincipalLayout = new javax.swing.GroupLayout(painelPrincipal);
        painelPrincipal.setLayout(painelPrincipalLayout);
        painelPrincipalLayout.setHorizontalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        painelPrincipalLayout.setVerticalGroup(
            painelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 355, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraBotoes, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(painelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(barraBotoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(painelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoClienteActionPerformed
        PainelGerenciarClientes painelClientes = new PainelGerenciarClientes();
        painelPrincipal.removeAll();
        this.painelPrincipal.setLayout(new BorderLayout());
        painelPrincipal.add(painelClientes);
        this.repaint();
    }//GEN-LAST:event_botaoClienteActionPerformed

    private void botaoEstoqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoEstoqueActionPerformed
        PainelGerenciarEstoque painelEstoque = new PainelGerenciarEstoque();
        painelPrincipal.removeAll();
        this.painelPrincipal.setLayout(new BorderLayout());
        painelPrincipal.add(painelEstoque);
        this.repaint();
    }//GEN-LAST:event_botaoEstoqueActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        PainelGerenciarProdutos painelProdutos = new PainelGerenciarProdutos();
        painelPrincipal.removeAll();
        this.painelPrincipal.setLayout(new BorderLayout());
        painelPrincipal.add(painelProdutos);
        this.repaint();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void apresentacaoBotaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_apresentacaoBotaoActionPerformed
        painelPrincipal.removeAll();
        painelPrincipal.add(painelInicial);
        this.repaint();

    }//GEN-LAST:event_apresentacaoBotaoActionPerformed

    private void zonaDoAdministradorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zonaDoAdministradorActionPerformed
      if (painelDoAdministrador==null) {  
        painelDoAdministrador = new PainelAdministrador();
        painelDoAdministrador.setJanelaPrincipal(this);
        painelDoAdministrador.setVisible(true);
        painelDoAdministrador.setZona(false);
      } else {
          painelDoAdministrador.setZona(false);
          painelDoAdministrador.setVisible(true);
          
      }
       
        
    }//GEN-LAST:event_zonaDoAdministradorActionPerformed

    private void gerarRelatoriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerarRelatoriosActionPerformed
        PainelGeracaoDeRelatorios painelRelatorios = new PainelGeracaoDeRelatorios();
        painelPrincipal.removeAll();
        this.painelPrincipal.setLayout(new BorderLayout());
        painelPrincipal.add(painelRelatorios);
        this.repaint();
    }//GEN-LAST:event_gerarRelatoriosActionPerformed

    private void vendaDeProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vendaDeProdutosActionPerformed
        if (painelDoAdministrador==null) {  
        painelDoAdministrador = new PainelAdministrador();
        painelDoAdministrador.setJanelaPrincipal(this);
        painelDoAdministrador.setVisible(true);
        painelDoAdministrador.setZona(true);
      } else {
          painelDoAdministrador.setVisible(true);
          painelDoAdministrador.setZona(true);
          
      }
    }//GEN-LAST:event_vendaDeProdutosActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JanelaPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton apresentacaoBotao;
    private javax.swing.JToolBar barraBotoes;
    private javax.swing.JButton botaoCliente;
    private javax.swing.JButton botaoEstoque;
    private javax.swing.JButton gerarRelatorios;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel painelPrincipal;
    private javax.swing.JButton vendaDeProdutos;
    private javax.swing.JButton zonaDoAdministrador;
    // End of variables declaration//GEN-END:variables
}
